package com.tutu.book.controller;


import com.tutu.book.service.BookService;
import com.tutu.commons.entity.Book;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Program: SpringCloud
 * @Description:
 * @Author: JK.TuTu
 * @Version: 1.0
 * @Create: 2022-12-01 13:08
 **/
@RestController
@RequestMapping("/book")
public class BookController {

    @Resource
    BookService service;

    @GetMapping("/{bid}")
    Book findBookById(@PathVariable("bid") int bid){
        //模拟比较复杂的业务逻辑 需要较长的处理时间
        /*try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }*/
        return service.getBookById(bid);
    }
}